package com.zhou.app.favourite.controller;


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.zhou.app.favourite.model.ao.FavAddressAo;
import com.zhou.app.favourite.service.service.impl.FavAddressServiceImpl;
import com.zhou.common.lib.model.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 收藏地址 前端控制器
 * </p>
 *
 * @author zxf
 * @since 2023-04-15
 */
@Api(tags = "收藏地址")
@ApiSupport(order = 285)
@RestController
@RequestMapping("/favourite/address")
public class FavAddressController {

    @Autowired
    private FavAddressServiceImpl favAddressService;

    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新增收藏接口")
    @PostMapping("/")
    public Response save(@Valid @RequestBody FavAddressAo addressAo) {
        favAddressService.save(addressAo);
        return Response.success();
    }

    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "删除收藏列表")
    @DeleteMapping("/{id}")
    public Response delete(@PathVariable Long id) {
        favAddressService.removeById(id);
        return Response.success();
    }

}
